package com.jswzc.common.api.controller;

import com.jswzc.api.service.emailUnified.EmailUnifiedServiceI;
import com.jswzc.framework.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by DeathCat on 2017/5/12.
 */
@Controller
@RequestMapping("/emailUnified")
public class EmailUnifiedController extends BaseController {

    @Resource(name = "emailUnifiedService")
    private EmailUnifiedServiceI emailUnifiedService;


    @RequestMapping(value = "/sendEmailTest")
    public void sendEmailTest(HttpServletResponse response, HttpServletRequest request, String addTo,String addFrom,String sub,String msg,String smtpType,String username,String password,String port) throws IOException {
        Map<String, Object> res = new HashMap<String, Object>();
        try {
            res = emailUnifiedService.sendEmail(addTo,addFrom,sub,msg,smtpType,username,password,port);
        } catch (Exception e) {
            res.put("res", "F");
            res.put("msg", "未知错误:" + e.getMessage());
        }
        writeJson(res,response);
    }


}
